package memorphic.simpleloginsample
{
	import flash.display.InteractiveObject;
	
	import memorphic.simpleloginsample.controllers.LoginController;
	import memorphic.simpleloginsample.model.Session;
	import memorphic.slide.IStateView;
	import memorphic.slide.SlidePresModelBase;
	import memorphic.slide.debugger.SlideDebugger;



	/**
	 * ROLE: App Main
	 *	The responsibilities of the App Main are to create and initialize controllers, models and views. The App Main 
	 * 		has knowledge of all the main pieces of the application and how they work together. Other pieces of the
	 * 		application may only know some of that information, (for example they may deal with an interface but not 
	 * 		know what the implementation is.)
	 *
	 */
	public class SampleAppMain extends SlidePresModelBase
	{
		private var rootContext:ISampleAppContext;
		
		private var stateManager:SampleStateManager;
		
		
		private var loginController:LoginController;
		
		
		public function SampleAppMain(rootContext:IStateView)
		{
			super(rootContext);
			this.rootContext = ISampleAppContext(rootContext);
			
			initApp();
		}
		
		private function initApp():void
		{
			loginController = new LoginController(rootContext);
			
			rootContext.loginController = loginController;
			rootContext.session = new Session();
			
			rootContext.stateManager = new SampleStateManager();
			
			// for debugging tools
			SlideDebugger.initContextMenu(rootContext as InteractiveObject);
		}
	}
}